//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101
//#include "stdafx.h"
#include "OvernightIndexedSwap.h"
using namespace Cephei::QL::Instruments;
#include <gen/QL/Times/DayCounter.h>
#include <gen/QL/CashFlow.h>
#include <gen/QL/Indexes/OvernightIndex.h>
#include <gen/QL/Times/Schedule.h>
#include <gen/QL/PricingEngine.h>
#include <gen/QL/Instruments/Swap.h>
using namespace Cephei::QL::Times;
using namespace Cephei::QL;
using namespace Cephei::QL::Indexes;
#define HANDLE
#undef ABSTRACT
#define STRUCT
Cephei::QL::Instruments::COvernightIndexedSwap::COvernightIndexedSwap (QL::Instruments::OvernightIndexedSwap::TypeEnum type, Double nominal, Cephei::QL::Times::ISchedule^ schedule, Double fixedRate, Cephei::QL::Times::IDayCounter^ fixedDC, Cephei::QL::Indexes::IOvernightIndex^ overnightIndex, Microsoft::FSharp::Core::FSharpOption<Double>^ spread, Cephei::QL::IPricingEngine^ QL_Pricer) : CSwap(COvernightIndexedSwap::typeid)
{
    CSchedule^ _Cschedule;
    CDayCounter^ _CfixedDC;
    COvernightIndex^ _CovernightIndex;
    try
    {
#ifdef HANDLE
        _phOvernightIndexedSwap = NULL;
#endif
        QuantLib::OvernightIndexedSwap::Type _type = (QuantLib::OvernightIndexedSwap::Type)type ;
        QuantLib::Real _nominal = (QuantLib::Real)ValueHelper::Convert (nominal);
        _Cschedule = safe_cast<CSchedule^> (schedule);
        _Cschedule->Lock();
        QuantLib::Schedule& _schedule = static_cast<QuantLib::Schedule&> (_Cschedule->GetReference ()); 
        QuantLib::Rate _fixedRate = (QuantLib::Rate)ValueHelper::Convert (fixedRate);
        _CfixedDC = safe_cast<CDayCounter^> (fixedDC);
        _CfixedDC->Lock();
        QuantLib::DayCounter& _fixedDC = static_cast<QuantLib::DayCounter&> (_CfixedDC->GetReference ()); 
        _CovernightIndex = safe_cast<COvernightIndex^> (overnightIndex);
        _CovernightIndex->Lock();
        boost::shared_ptr<QuantLib::OvernightIndex>& _overnightIndex = static_cast<boost::shared_ptr<QuantLib::OvernightIndex>&> (_CovernightIndex->GetShared ()); 
        QuantLib::Spread _spread = 
            (Microsoft::FSharp::Core::FSharpOption<Double>::IsSome::get (spread) ? (QuantLib::Spread)ValueHelper::Convert (spread->Value) : 0.0); //4
        _ppOvernightIndexedSwap = new boost::shared_ptr<QuantLib::OvernightIndexedSwap> (new QuantLib::OvernightIndexedSwap ( _type,  _nominal,  _schedule,  _fixedRate,  _fixedDC,  _overnightIndex,  _spread ));
        CPricingEngine^ _CQL_Pricer = safe_cast<CPricingEngine^> (QL_Pricer);
        boost::shared_ptr<QuantLib::PricingEngine>& _QL_Pricer = static_cast<boost::shared_ptr<QuantLib::PricingEngine>&> (_CQL_Pricer->GetShared ());
        (*_ppOvernightIndexedSwap)->setPricingEngine (_QL_Pricer);
        SetSwap (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppOvernightIndexedSwap));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
        if (_Cschedule != nullptr) _Cschedule->Unlock();
        if (_CfixedDC != nullptr) _CfixedDC->Unlock();
        if (_CovernightIndex != nullptr) _CovernightIndex->Unlock();
    }
}
Cephei::QL::Instruments::COvernightIndexedSwap::COvernightIndexedSwap (boost::shared_ptr<QuantLib::OvernightIndexedSwap>& childNative, Object^ owner) : CSwap(COvernightIndexedSwap::typeid)
{
#ifdef HANDLE
	_phOvernightIndexedSwap = NULL;
#endif
	_ppOvernightIndexedSwap = &childNative;
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppOvernightIndexedSwap));
}
Cephei::QL::Instruments::COvernightIndexedSwap::COvernightIndexedSwap (QuantLib::OvernightIndexedSwap& childNative, Object^ owner) : CSwap(COvernightIndexedSwap::typeid)
{
#ifdef HANDLE
	_phOvernightIndexedSwap = NULL;
#endif
	_ppOvernightIndexedSwap = new boost::shared_ptr<QuantLib::OvernightIndexedSwap> (&childNative);
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppOvernightIndexedSwap));
    _OvernightIndexedSwapOwner = owner;
    _SwapOwner = owner;
}

Cephei::QL::Instruments::COvernightIndexedSwap::COvernightIndexedSwap (COvernightIndexedSwap^ copy) : CSwap(COvernightIndexedSwap::typeid)
{
#ifdef HANDLE
	_phOvernightIndexedSwap = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppOvernightIndexedSwap = new boost::shared_ptr<QuantLib::OvernightIndexedSwap> (copy->GetShared());
        _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppOvernightIndexedSwap));
    }
}
Cephei::QL::Instruments::COvernightIndexedSwap::COvernightIndexedSwap (System::Type^ t) : CSwap(COvernightIndexedSwap::typeid)
{
#ifdef HANDLE
	_phOvernightIndexedSwap = NULL;
#endif
	if (!t->IsSubclassOf(COvernightIndexedSwap::typeid))
		throw gcnew Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Instruments::COvernightIndexedSwap::COvernightIndexedSwap (QuantLib::Handle<QuantLib::OvernightIndexedSwap>& childNative, Object^ owner)  : CSwap(COvernightIndexedSwap::typeid)
{
	_phOvernightIndexedSwap = &childNative;
	_ppOvernightIndexedSwap = &static_cast<boost::shared_ptr<QuantLib::OvernightIndexedSwap>>(childNative.currentLink());
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppOvernightIndexedSwap));
    _OvernightIndexedSwapOwner = owner;
}
Cephei::QL::Instruments::COvernightIndexedSwap::COvernightIndexedSwap (QuantLib::Handle<QuantLib::OvernightIndexedSwap> childNative)  : CSwap(COvernightIndexedSwap::typeid)
{
	_phOvernightIndexedSwap = &childNative;
	_ppOvernightIndexedSwap = &static_cast<boost::shared_ptr<QuantLib::OvernightIndexedSwap>>(childNative.currentLink());
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppOvernightIndexedSwap));
}
#endif
#ifdef STRUCT
Cephei::QL::Instruments::COvernightIndexedSwap::COvernightIndexedSwap (QuantLib::OvernightIndexedSwap childNative)  : CSwap(COvernightIndexedSwap::typeid)
{
#ifdef HANDLE
	_phOvernightIndexedSwap = NULL;
#endif
	_ppOvernightIndexedSwap = new boost::shared_ptr<QuantLib::OvernightIndexedSwap> (new QuantLib::OvernightIndexedSwap (childNative));
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppOvernightIndexedSwap));
}
#endif

Cephei::QL::Instruments::COvernightIndexedSwap::~COvernightIndexedSwap ()
{
    if (_ppOvernightIndexedSwap != NULL)
    {
	    delete _ppOvernightIndexedSwap;
        _ppOvernightIndexedSwap = NULL;
    }
}
Cephei::QL::Instruments::COvernightIndexedSwap::!COvernightIndexedSwap ()
{
    if (_ppOvernightIndexedSwap != NULL)
    {
	    delete _ppOvernightIndexedSwap;
    }
}
QuantLib::OvernightIndexedSwap& Cephei::QL::Instruments::COvernightIndexedSwap::GetReference ()
{
    if (_ppOvernightIndexedSwap == NULL) throw gcnew NativeNullException ();
	return **_ppOvernightIndexedSwap;
}
boost::shared_ptr<QuantLib::OvernightIndexedSwap>& Cephei::QL::Instruments::COvernightIndexedSwap::GetShared ()
{
    if (_ppOvernightIndexedSwap == NULL) throw gcnew NativeNullException ();
	return *_ppOvernightIndexedSwap;
}
QuantLib::OvernightIndexedSwap* Cephei::QL::Instruments::COvernightIndexedSwap::GetPointer ()
{
    if (_ppOvernightIndexedSwap == NULL) throw gcnew NativeNullException ();
	return &**_ppOvernightIndexedSwap;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::OvernightIndexedSwap>& Cephei::QL::Instruments::COvernightIndexedSwap::GetHandle ()
{
	if (_phOvernightIndexedSwap == NULL)
	{
		_phOvernightIndexedSwap = new Handle<QuantLib::OvernightIndexedSwap> (*_ppOvernightIndexedSwap);
	}
	return *_phOvernightIndexedSwap;
}
#endif
bool Cephei::QL::Instruments::COvernightIndexedSwap::HasNative () 
{
	return (_ppOvernightIndexedSwap != NULL);
}

Double Cephei::QL::Instruments::COvernightIndexedSwap::FairRate::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppOvernightIndexedSwap)->fairRate ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::COvernightIndexedSwap::FairSpread::get ()
{
    try
    {
    	QuantLib::Spread _rv = (QuantLib::Spread)(*_ppOvernightIndexedSwap)->fairSpread ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Times::IDayCounter^ Cephei::QL::Instruments::COvernightIndexedSwap::FixedDayCount::get ()
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
    	QuantLib::DayCounter& _rv = (QuantLib::DayCounter&)(*_ppOvernightIndexedSwap)->fixedDayCount ( );   
        Cephei::QL::Times::CDayCounter^ _nrv = gcnew Cephei::QL::Times::CDayCounter (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::IVector<Cephei::QL::ICashFlow^>^ Cephei::QL::Instruments::COvernightIndexedSwap::FixedLeg::get ()
{
    try
    {
    	std::vector<boost::shared_ptr<QuantLib::CashFlow> >& _rv = (std::vector<boost::shared_ptr<QuantLib::CashFlow> >&)(*_ppOvernightIndexedSwap)->fixedLeg ( );   
        CoVector<Cephei::QL::ICashFlow^>^ _nrv = gcnew CoVector<Cephei::QL::ICashFlow^>(gcnew CCashFlowVector (_rv, this));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::COvernightIndexedSwap::FixedLegBPS::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppOvernightIndexedSwap)->fixedLegBPS ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::COvernightIndexedSwap::FixedLegNPV::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppOvernightIndexedSwap)->fixedLegNPV ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::COvernightIndexedSwap::FixedRate::get ()
{
    try
    {
    	QuantLib::Rate _rv = (QuantLib::Rate)(*_ppOvernightIndexedSwap)->fixedRate ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::COvernightIndexedSwap::Nominal::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppOvernightIndexedSwap)->nominal ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Indexes::IOvernightIndex^ Cephei::QL::Instruments::COvernightIndexedSwap::OvernightIndex::get ()
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
    	boost::shared_ptr<QuantLib::OvernightIndex>& _rv = (boost::shared_ptr<QuantLib::OvernightIndex>&)(*_ppOvernightIndexedSwap)->overnightIndex ( );   
        Cephei::QL::Indexes::COvernightIndex^ _nrv = gcnew Cephei::QL::Indexes::COvernightIndex (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::IVector<Cephei::QL::ICashFlow^>^ Cephei::QL::Instruments::COvernightIndexedSwap::OvernightLeg::get ()
{
    try
    {
    	std::vector<boost::shared_ptr<QuantLib::CashFlow> >& _rv = (std::vector<boost::shared_ptr<QuantLib::CashFlow> >&)(*_ppOvernightIndexedSwap)->overnightLeg ( );   
        CoVector<Cephei::QL::ICashFlow^>^ _nrv = gcnew CoVector<Cephei::QL::ICashFlow^>(gcnew CCashFlowVector (_rv, this));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::COvernightIndexedSwap::OvernightLegBPS::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppOvernightIndexedSwap)->overnightLegBPS ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::COvernightIndexedSwap::OvernightLegNPV::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppOvernightIndexedSwap)->overnightLegNPV ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
QL::Times::FrequencyEnum Cephei::QL::Instruments::COvernightIndexedSwap::PaymentFrequency::get ()
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
    	QuantLib::Frequency _rv = (QuantLib::Frequency)(*_ppOvernightIndexedSwap)->paymentFrequency ( );   
        QL::Times::FrequencyEnum _nrv = (QL::Times::FrequencyEnum)_rv;
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::COvernightIndexedSwap::Spread::get ()
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
    	QuantLib::Spread _rv = (QuantLib::Spread)(*_ppOvernightIndexedSwap)->spread ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
QL::Instruments::OvernightIndexedSwap::TypeEnum Cephei::QL::Instruments::COvernightIndexedSwap::Type::get ()
{
    try
    {
    	QuantLib::OvernightIndexedSwap::Type _rv = (QuantLib::OvernightIndexedSwap::Type)(*_ppOvernightIndexedSwap)->type ( );   
        QL::Instruments::OvernightIndexedSwap::TypeEnum _nrv = (QL::Instruments::OvernightIndexedSwap::TypeEnum)_rv;
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Instruments::IOvernightIndexedSwap^ Cephei::QL::Instruments::COvernightIndexedSwap_Factory::Create (QL::Instruments::OvernightIndexedSwap::TypeEnum type, Double nominal, Cephei::QL::Times::ISchedule^ schedule, Double fixedRate, Cephei::QL::Times::IDayCounter^ fixedDC, Cephei::QL::Indexes::IOvernightIndex^ overnightIndex, Microsoft::FSharp::Core::FSharpOption<Double>^ spread, Cephei::QL::IPricingEngine^ QL_Pricer)
{
    return gcnew COvernightIndexedSwap ( type,  nominal,  schedule,  fixedRate,  fixedDC,  overnightIndex,  spread,  QL_Pricer);
}
